Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: LWJGL Slick-util DrawString Not Working on: 2014-01-14 23:32:43
Ignore please, I fixed it myself. Problem was due to lack of clean code. Rewrote everything. Its good.
2  Game Development / Newbie & Debugging Questions / LWJGL Slick-util DrawString Not Working on: 2014-01-14 22:11:50
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
package engine;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;

public class Window {
   
   private static String title = "Ultimate Tetris";
   private static String version = "Alpha";
   private int width;
   private int height;
   private boolean fullScreen;
   private boolean vSync;
   public static boolean play = true;
   
   public Window(){
      //Load Settings
     Settings settings = new Settings();
     
      fullScreen = settings.getFullScreen();
      width = settings.getScreenWith();
      height = settings.getScreenWith();
      vSync = settings.getVSync();
     
      //Initialize Game Settings
     initialize();
   }
   
   public void initialize(){
      try{
         //Load Window
        if(fullScreen){
            Display.setFullscreen(fullScreen);
         }else{
            Display.setDisplayMode(new DisplayMode(width, height));
         }
         Display.setTitle(title + " " + version);
         Display.setVSyncEnabled(true);
         Display.create();
   
         GL11.glEnable(GL11.GL_TEXTURE_2D);    
         GL11.glDisable(GL11.GL_DEPTH_TEST);
         
         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
   
           GL11.glViewport(0,0,width,height);
         GL11.glMatrixMode(GL11.GL_MODELVIEW);
   
         GL11.glMatrixMode(GL11.GL_PROJECTION);
         GL11.glLoadIdentity();
         GL11.glOrtho(0, width, height, 0, 1, -1);
         GL11.glMatrixMode(GL11.GL_MODELVIEW);
      }catch(LWJGLException e){
         e.printStackTrace();
         System.out.println("GAME EXITING\nFAILED TO INITIALIZE GAME DATA!");
         System.out.println("Error: Window.initialize() " + e);
         Window.play = false;
         System.exit(0);
      }
   }
   
   public static void main(String[] args){
      new Window();
      GameState state = new GameState();
     
      while(play && !Display.isCloseRequested()){
         GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
         
         state.updateGameState();
         
         Display.update();
         Display.sync(100);
      }  
     
      Display.destroy();
   }
}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
package engine;

import org.lwjgl.Sys;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;

import java.awt.Font;
 

import org.newdawn.slick.Color;
import org.newdawn.slick.TrueTypeFont;

public class Debug {  
   private int fps = 0;
   private String FPS = "";
   private long lastLoopTime = getTime();
   private long lastFPSTime;
   private static long timerTicksPerSecond = Sys.getTimerResolution();
   private TrueTypeFont font;
   public boolean debugON = false;
   
   
   public Debug(){
      Font awtFont = new Font("Times New Roman", Font.BOLD, 24);
      font = new TrueTypeFont(awtFont, true);
   }
   
   private long getTime(){
      return (Sys.getTime() * 1000) / timerTicksPerSecond;
   }
   
   private void sleep(long time){
      try{
         Thread.sleep((time * timerTicksPerSecond) / 1000);
      }catch(InterruptedException e){
         e.printStackTrace();
         System.out.println("Error: Debug.sleep() " + e);
      }
   }
   
   public String getOSVersion(){
      return System.getProperty("os.version");
   }
   
   public String getOSName(){
      return System.getProperty("os.name");
   }
   
   public String getOSType(){
      return System.getProperty("os.arch");
   }
   
   public String getJavaVersion(){
      return System.getProperty("java.version");
   }
   
   public String getJavaVendor(){
      return System.getProperty("java.vendor");
   }
   
   public String getMaxRAM(){
      return Long.toString(Runtime.getRuntime().maxMemory()) + " bytes";
   }
   
   public String getTotalRAM(){
      return Long.toString(Runtime.getRuntime().totalMemory()) + " bytes";
   }
   
   public String getFreeRAM(){
      return Long.toString(Runtime.getRuntime().freeMemory()) + " bytes";
   }
   
   public String getCPUCores(){
      return Integer.toString(Runtime.getRuntime().availableProcessors());
   }
   
   public String getFPS(){
      return FPS;
   }
   
   public String getMousePosition(){
      return "X: " + Mouse.getX() + " Y: " + Mouse.getY();
   }
   
   public void calculateFPS(){
      long delta = getTime() - lastLoopTime;
      lastLoopTime = getTime();
      lastFPSTime += delta;
      fps++;
     
      if(lastFPSTime >= 1000){
         FPS = Integer.toString(fps);
         lastFPSTime = 0;
         fps = 0;
      }
   }
   
   public void draw(){
      font.drawString(10, 10, "Hello World");
   }
}


My code is based off of the tutorial created by NeHe (http://lwjgl.org/wiki/index.php?title=Slick-Util_Library_-_Part_3_-_TrueType_Fonts_for_LWJGL), and it works when I tested it out as exactly shown on the website, but when I tried to integrate it into my game engine, it no longer works.
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (17 views)
2014-07-30 21:08:39

Riven (23 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43
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!