Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Loading and rendering bitmaps  (Read 1291 times)
0 Members and 1 Guest are viewing this topic.
Offline xxdaggerxx

Junior Newbie





« Posted 2006-09-26 08:21:18 »

Hi guys im new to java and opengl and im in the middle of a making a system to load and render bitmaps mainly for fonts. I got all the loading stuff working (at least i think it is) but i cant render the bitmap to my screen.

heres the code i use to load the bitmap


bytebuffer = ByteBuffer.allocateDirect(256);
FileInputStream in = null;
      
int c;
int i = 0;

try{
//create the file input stream
in = new FileInputStream("fonts.bmp");
//read the file and put it into the byte buffer
while((c = in.read()) != -1){
bytebuffer.put((byte)c);
i++;
}
//catch any errors   
} catch(Exception  e){
System.out.println(e);
e.printStackTrace();
}

//make sure stream is closed.       
if (in != null) {
try{
           
in.close();
}catch(IOException e){
System.out.println("Close error");
}
}

The above code reads from a file called fonts.bmp, its a bitmap image of a word (made in MS paint, monochrome).
Im just practising how to load bitmaps.
Any way i have this in my render loop

GL11.glRasterPos2i (20, 20);
GL11.glColor3f (1.0f, 1.0f, 1.0f);
GL11.glBitmap (32, 8, 0.0f, 0.0f, 11.0f, 0.0f, bytebuffer);

and this in my init method
GL11.glPixelStorei (GL11.GL_UNPACK_ALIGNMENT, 1);

I get no fonts on the screen, while evrything else renders fine.

Offline g666

Junior Member





« Reply #1 - Posted 2006-09-26 09:20:09 »

The .bmp format is a little more complex than just an array of bitmap data, google for it.

desperately seeking sanity
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #2 - Posted 2006-09-26 11:11:30 »

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=17 - NeHe lesson 17.  Bitmap texture to make fonts.  Go to the bottom of the page for the LWJGL version.

http://www.gamedev.net/reference/articles/article1966.asp - Article shows how to load a bitmap.  It is in C++, but should still be easy to follow.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (35 views)
2014-09-24 16:13:29

Pippogeek (28 views)
2014-09-24 16:12:22

Pippogeek (17 views)
2014-09-24 16:12:06

Grunnt (40 views)
2014-09-23 14:38:19

radar3301 (23 views)
2014-09-21 23:33:17

BurntPizza (59 views)
2014-09-21 02:42:18

BurntPizza (29 views)
2014-09-21 01:30:30

moogie (34 views)
2014-09-21 00:26:15

UprightPath (47 views)
2014-09-20 20:14:06

BurntPizza (51 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!